package xyz.scootaloo.oj.leetcode

import org.junit.Test
import xyz.scootaloo.common.TestDsl

/**
 * @author flutterdash@qq.com
 * @since 2021/7/3 10:45
 */
class P70 : TestDsl {

    private fun climbStairs(n: Int): Int {
        fun fib(number: Int): Int {
            val dp = intArrayOf(1, 1)
            for (i in 2..number) {
                val sum = dp[0] + dp[1]
                dp[0] = dp[1]
                dp[1] = sum
            }
            return dp[1]
        }

        if (n == 0)
            return 0
        if (n == 1)
            return 1
        return fib(n)
    }

    @Test
    fun test0() {
        climbStairs(2) shouldBe 2
        climbStairs(3) shouldBe 3
    }

}
